package com.sample.base.base;

import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;

import com.loyal.helper.PermissionHelper;
import com.loyal.helper.UIHelper;
import com.loyal.ui.activity.BasicActivity;

import java.util.Map;

public abstract class BaseActivity extends BasicActivity implements PermissionHelper.SingleCallback, PermissionHelper.MultipleCallback {

    @Override
    public void singlePermissionCallback(boolean successful) {
    }

    @Override
    public void multiplePermissionsCallback(@NonNull Map<String,Boolean> refuseMap) {
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        boolean touch = super.dispatchTouchEvent(ev);
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            View v = getCurrentFocus();
            if (null != v) {
                if (UIHelper.isShouldHideKeyboard(v, ev)) {
                    UIHelper.hideKeyBoard(v);
                }
            }
        }
        return touch;
    }
}
